package com.azkj.album.presenter;

import com.azkj.album.dto.BannerBean;
import com.azkj.album.network.NetworkMaster;
import com.azkj.album.network.callback.ServiceCallback;
import com.azkj.album.network.networkframe.bean.BaseResp;
import com.azkj.album.network.networkframe.net.exception.ApiException;
import com.azkj.album.view.base.BasePresenter;
import com.azkj.album.view.iview.IBannerView;
import com.azkj.album.view.widgets.dialog.DialogHelper;

import java.util.List;

public class BannerPresenter extends BasePresenter {

    private final IBannerView iView;


    public BannerPresenter(IBannerView iView) {
        this.iView = iView;
    }


    public void getBanner() {

        NetworkMaster.getInstance().getCommonService().getBanner(new ServiceCallback<BaseResp<List<BannerBean>>>() {
            @Override
            public void onSuccess(BaseResp<List<BannerBean>> jsonObj) {
//                DialogHelper.hideDialog();
                if (jsonObj.getCode() == 1) {
                    iView.getBannerSuccess(jsonObj.getData());
                } else {
                    iView.getBannerFail(jsonObj.getMsg());
                }
            }

            @Override
            public void onError(ApiException apiException) {
                iView.getBannerFail(apiException.errorInfo.error);
            }

        });
    }

    public void clickBanner(String id) {

        NetworkMaster.getInstance().getCommonService().clickBanner(id, new ServiceCallback<BaseResp>() {
            @Override
            public void onSuccess(BaseResp jsonObj) {

            }

            @Override
            public void onError(ApiException apiException) {

            }

        });
    }

}
